__author__ = 'aesop'

import re
#pattern @#xxx#
#your type is too strong
#pattern @#xxx#
def render(str, dic):
    str1 = str
    pattern_list = re.findall(r'@#[^#]+#',str)
    print pattern_list
    it = iter(pattern_list)
    try:
        while(True):
            val = it.next()
            dic_val = dic[val[2:-1]]
            if(isinstance(dic_val, basestring)):
                str1 = re.sub(val,dic_val,str1)
            else:
                str1 = re.sub(val,bytes(dic_val),str1)
    except StopIteration:
         pass

    return str1


